﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SchoolManagementSystem
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (username.Text == "") 
            {
                 MessageBox.Show("Isi terlebih dahulu username Anda !", "Peringatan !");
            }
            else if (password.Text == "")
            {
                MessageBox.Show("Isi terlebih dahulu password Anda !", "Peringatan !");
            }
            else if (Database.getInstance().checkLoginID(username.Text, password.Text))
            {
                Database.getInstance().logSistem("Login ke sistem");
                this.Hide();
                Main main = new Main(this);
                main.Show();
            }
            else
            {
                MessageBox.Show("Maaf, akun ini tidak ditemukan !", "Peringatan !");
            }

            username.Clear();
            password.Clear();   
        }  
    }
}
